home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: EU.net!sun4nl!hcsrnd!root
- From: paulw@gti-ia.nl (Paul Wallis)
- Subject: Pre-processing: Can this be done?
- Message-ID: <DMGo4t.7r7@gti-ia.nl>
- Sender: root@gti-ia.nl (Operator)
- Reply-To: paulw@gti-ia.nl
- Organization: GTI Industrial Automation, Apeldoorn
- Date: Thu, 8 Feb 1996 14:26:52 GMT
-
- Hi all,
-
- I'm trying to write a function which will print trace statements.
- I want the file and line to be added to the argument list
- automatically. I am, however, having some problems working
- my way around the pre-processor. I would like to be able to enter
- the following line:
-
- trace("%d, %f", an_int, a_float);
-
- and have the arguments passed as so:
-
- _trace(__FILE__, __LINE__, "%d, %f", an_int, a_float);
-
- I have defined a macro trace so:
-
- #define trace(x) _trace(__FILE__, __LINE__, x)
-
- Now what I've found is that the pre-processor 'throws a wobbler'
- at the x. Apparently not liking multiple arguments. Is there
- any way to get it to accept this, without having to do this,
- which is very ugly:
-
- trace(("%d, %f", an_int, a_float));
-
- I have also tried redefining a macro as such:
-
- #define trace( _trace(__FILE__, __LINE__
-
- but to no avail. Is there an answer, or am I stuck with the
- ugly?
-
- Thanks in advance for any help,
-
- Paul
-
- ---
- = =
- === === GTI Contact me at
- ============ Industrial paulw@gti-ia.nl
- = = Automation b.v.
- === === My opinions are
- ============ The Netherlands Mine all mine!
-
-
-